<template>
  <vab-dialog v-model="isShowDialog" :close-on-click-modal="true" show-fullscreen width="80%">
    <template #default>
      <div class="table-box">
        <KingTable ref="kingTable" :tableOptions="_tableOptions">
          <template #tableHeader>
            <span><!-- 占位不显示表格上面的按钮 --></span>
          </template>
        </KingTable>
      </div>
    </template>
  </vab-dialog>
</template>

<script setup lang="tsx" name="RoleList">
import VabDialog from "@/plugins/VabDialog/index.vue";
import { ref, reactive } from "vue";
import KingTable from "@/components/KingTable/index.vue";

const isShowDialog = ref(false);

// 获取 KingTable 元素，调用其获取刷新数据方法（还能获取到当前查询参数，方便导出携带参数）
const kingTable = ref();

// 如果表格需要初始化请求参数，直接定义传给 KingTable(之后每次请求都会自动带上该参数，此参数更改之后也会一直带上，改变此参数会自动刷新表格数据)
const _initParam = reactive({ EQ_jobId: "", EQ_ss: 1 });

// 表格配置项
const _tableCols = [
  { type: "selection", fixed: "left", align: "center", width: 60 },
  { type: "index", label: "序号", align: "center", width: 60 },
  {
    prop: "jobName",
    label: "任务名称",
    width: 180
  },
  {
    prop: "jobGroup",
    label: "任务组名",
    dictCode: "sys_job_group",
    width: 180
  },
  {
    prop: "invokeTarget",
    label: "调用目标字符串",
    width: 180
  },
  {
    prop: "status",
    label: "执行状态",
    dictCode: "sys_common_status",
    width: 100
  },
  {
    prop: "cts",
    label: "执行时间",
    width: 180
  },
  {
    prop: "startTime",
    label: "开始时间",
    width: 180
  },
  {
    prop: "stopTime",
    label: "停止时间",
    width: 180
  },
  {
    prop: "jobMessage",
    label: "日志信息",
    width: 180,
    overflow: true
  }
];

const _searchCols = [
  {
    prop: "LIKE_jobName",
    label: "任务名称",
    width: 100,
    el: "input"
  },
  {
    prop: "EQ_jobGroup",
    label: "任务组名",
    width: 100,
    el: "select",
    dictCode: "sys_job_group"
  },
  {
    prop: "EQ_status",
    label: "执行状态",
    width: 100,
    el: "select",
    dictCode: "sys_common_status"
  }
];

const _tableOptions = {
  title: "定时任务",
  queryUrl: "monitor/jobLog/query",
  operUrl: "monitor/jobLog",
  tableColumns: _tableCols,
  searchColumns: _searchCols,
  initParam: _initParam
};

const showDialog = (row: any) => {
  isShowDialog.value = true;
  _initParam.EQ_jobId = row.id;
};

defineExpose({ showDialog });
</script>
